Julia and the BEFWM2 using VSCode

Author

Danet and Becks, based on originals by Delmas and Griffiths

Published

November 8, 2024

Welcome to the Tutorials

This set of tutorials is designed to help you use an integrated coding tool, VSCode, to run experiments with the Bioenergetic Foodweb Model, built in the coding language Julia.

It will cover four core objectives

  1. acquire/install the Julia programming language, the Integrated Development Environment called VSCode, and the Bioenergetic Food Web Model written in the Julia programming language.
  2. Learn how to work with Julia programming, from installing packages to understanding arithmetic and plotting and data frames
  3. Learn how to simulate a simple predator-prey (consumer-resource) model using the DifferentialEquations package in Julia
  4. Learn how to implement and use the multi-species BioenergeticFoodWebModel in Julia

Having done these, you will then be introduced to further complexities and opportunities.

Moving from R and RStudio to Julia and VSCode

For users of R and RStudio, VSCode and Julia can be thought of as the same working team, i.e. VSCode/RStudio are the text editors that allow you to create a ‘rich text’ environment from which to run Julia/R. That being said that (as to be expected) there are a few differences in the workflow that it might be worth familiarising yourself with.

RStudio users might be familiar with the concept of working with projects (i.e. a way of ‘containerising’ your work within a specific directory), Julia works in a similar manner, but at a much more local level. Broadly a Julia project is much more localised in that any packages that are imported (installed) locally for that specific project, meaning that it is possible to have multiple versions of a package installed for different projects - which is very handy from a reproducibility perspective. The details of the packages (dependencies) that you install are recorded in the Project.toml and the Manifest.toml files. These files are machine generated and will update as you add or removed packages while you work. For an R specific analogy these files can be thought as the equivalents of those generated when using the {renv} package.

If you are a user of R and RStudio, you are likely familiar with setting RStudio and R up to use a project file, the .RProject inside a project folder. You are also used to downloading and installing packages into R on your computer, and then invoking their use in each script using the library() function.

In the world of VSCode and Julia, we do something similar. You will create project folders, just like we recommend for R. Inside this folder, two files will be created, the Project.toml and the Manifest.toml. These are not really the same as the .RProject file. In Julia, each project has a set of packages that are associated with it. This is different from the more ‘global’ installation of packages in R.

There are some parallels… first, adding packages in Julia uses the Pkg toolbox and gets them from the Julia Language Ecosystem. This is like downloading them from CRAN for R. Second, making packages available for use in a Julia script requires the using function, which is a lot like the library() function.

Anyhow, the goal IS to try and make a workflow for Julia and VSCode that acts like the R and RStudio setup you are familiar with.

How to use these tutorials

The simple idea here is to make a Julia script and add the code in these tutorials to your scripts. Make sure you annotate using the # symbol, as we do in R Scripts. We suggest that You have a script associated with each section of the table of contents on the left.